#!/bin/sh

network=""
battery=""
clock=""
mkdir -p /tmp/swaybar/
mkfifo /tmp/swaybar/pipe 2>/dev/null

while true
do
	read -r line </tmp/swaybar/pipe 2>/dev/null
	name=$(echo "$line" | cut -d '|' -f1)
	module=$(echo "$line" | cut -d '|' -f2-)
	case $name in
		network)
			network=$module
			;;
		battery)
			battery=$module
			;;
		clock)
			clock=$module
			;;
		bluetooth)
			bluetooth=$module
			;;
	esac
	printf "%s %s   %s   %s\n" "$bluetooth" "$network" "$battery" "$clock"
done

